package com.simpletour.qa.common.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 权限资源
 * @author zhaohw
 * @date 2018-06-19 17:44
 */
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(schema = "qa",name = "t_authority")
public class Authority implements Serializable {

    /**
     * uri请求权限
     */
    public final static String AUTHORITY_TYPE_URI = "URI";

    /**
     * 前端按钮显示权限
     */
    public final static String AUTHORITY_TYPE_BUTTON = "BUTTON";

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Integer id;

    private String type;

    private String name;

    private String uri;

    private String method;

    @JsonBackReference
    @ManyToMany(mappedBy = "authorities")
    private List<Role> roles;

}
